//package cn.chengpengper.seckill.common.event.publisher.rocketmq;
//
//import cn.chengpengper.seckill.common.constants.SeckillConstants;
//import cn.chengpengper.seckill.common.event.SeckillBaseEvent;
//import cn.chengpengper.seckill.common.event.publisher.EventPublisher;
//import com.alibaba.fastjson.JSONObject;
//import lombok.RequiredArgsConstructor;
//import org.apache.rocketmq.spring.core.RocketMQTemplate;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
//import org.springframework.messaging.Message;
//import org.springframework.messaging.support.MessageBuilder;
//import org.springframework.stereotype.Component;
//
///**
// * @author chengpeng.hu
// */
//@Component
//@RequiredArgsConstructor
//@ConditionalOnProperty(name = "event.publish.type", havingValue = "rocketmq")
//public class RocketMqDomainEventPublisher implements EventPublisher {
//
//    private final RocketMQTemplate rocketMQTemplate;
//
//    @Override
//    public void publish(SeckillBaseEvent domainEvent) {
//        rocketMQTemplate.send(domainEvent.getTopicEvent(), getEventMessage(domainEvent));
//    }
//
//    private Message<String> getEventMessage(SeckillBaseEvent domainEvent){
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put(SeckillConstants.EVENT_MSG_KEY, domainEvent);
//        return MessageBuilder.withPayload(jsonObject.toJSONString()).build();
//    }
//}
